import React, { useEffect, useState } from "react";
import { useLocation, useParams } from "react-router-dom";
import { store } from "../../store";
import { connect, useSelector, useDispatch } from "react-redux";

const Index = (props: any) => {
  const location = useLocation();
  const params = useParams();
  const count = useSelector((state: any) => state.count);
	const dispatch = useDispatch()
  return (
    <div>
      <h1>登录</h1>
      <h2>{props.count}</h2>
      <button onClick={props.add}>+1</button>
      <hr />
      <h2>{count}</h2>
			<button onClick={() => dispatch({ type: 'add' })}>+1</button>
    </div>
  );
};

const mapStateToProps = (state: any) => {
  return {
    count: state.count,
  };
};

const mapDispatchToProps = (dispatch: any) => {
  return {
    add() {
      dispatch({ type: "add" });
    },
  };
};

export const ConnectIndex = connect(mapStateToProps, mapDispatchToProps)(Index);
export default ConnectIndex;


function Pdd() {

}

